package com.cuit.washneedshake.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cuit.washneedshake.model.dto.NationalNewTrendsResp;
import com.cuit.washneedshake.model.entity.NationalNewTrends;
import com.cuit.washneedshake.service.NationalNewTrendsService;
import com.cuit.washneedshake.mapper.NationalNewTrendsMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.LinkedList;


@Service
public class NationalNewTrendsServiceImpl extends ServiceImpl<NationalNewTrendsMapper, NationalNewTrends>
        implements NationalNewTrendsService {

    NationalNewTrendsResp nationalNewTrends;

    @Resource
    NationalNewTrendsMapper nationalNewTrendsMapper;

    @Override
    public LinkedList<NationalNewTrendsResp> getNationalNewTrendsInfo(){
        LinkedList<NationalNewTrendsResp> resList = new LinkedList<>();

        for(int i = 1;i <= 15;i ++){
            nationalNewTrends = new NationalNewTrendsResp();
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM.dd");
            String date = simpleDateFormat.format(nationalNewTrendsMapper.getDate(i));
            nationalNewTrends.setDate(date);
            nationalNewTrends.setNew_confirmed(nationalNewTrendsMapper.getNew_ConfirmedById(i));
            nationalNewTrends.setNew_suspected(nationalNewTrendsMapper.getNew_SuspectedById(i));
            resList.add(nationalNewTrends);
        }
        return resList;

    }


}





